#ifndef TLIST_H_

	#define TLIST_H_

	#include <iostream>
	#include "tsubtitle.h"
	#include <vector>

	using namespace std;

    // operator << sintax
	const char LISTCOM_FIRST = '{';
	const char LISTCOM_SEPARATION = ' ';
	const char LISTCOM_LAST	 = '}';

	class TList;

    // Clase TListNode.
	class TListNode
	{
		friend class TListPos;
		friend class TList;

        // operator << overload
		friend ostream &operator<<(ostream &os, const TList &lc);

		public:
            // Default constructor
			TListNode(void);
			
			TListNode(const TSubtitle &s1);

			// Copy constructor
			TListNode(const TListNode &ln);

            // Destructor
			~TListNode(void);


            // Asignation operator
			TListNode &operator=(const TListNode &ln);
	
		private:
            // Object primitive
			TSubtitle s;

            // Next and Previous nodes
			TListNode *next, *prev;
	};
	
    // Clase TList
	class TList
	{
		friend class TListNode;
        // operator << overload
		friend ostream & operator<<(ostream &os, const TList &lc);

		public:
            // Default constructor
			TList(void);

			// Copy constructor
			TList(const TList &tc);

			// Destructor
			~TList(void);


            // Asignation operator
			TList &operator=(const TList &lc);

			// operator == overload
			bool operator==(const TList &lc) const;

			// operator != overload
			bool operator!=(const TList &lc) const;


            // Whether it's empty or not
			bool IsEmpty(void) const;

			// TList lengthLongitud de la lista.
			int Length(void) const ;

			// First position
			TListNode *First(void) const;

			// Last position
			TListNode *Last(void) const;

			TSubtitle &Get(int id);

			// Insert -> Position by ID
			bool Insert(const TSubtitle &s);

       			// Insert -> TOP
			bool InsTop(const TSubtitle &s);

			// Insert -> TAIL
			bool InsTail(const TSubtitle &s);

			// Insert -> LEFT
			bool InsLeft(const TSubtitle &s, TListNode *ln);

			// Insert -> RIGHT
			bool InsRight(const TSubtitle &s, TListNode *ln);
			
			// Erase TSubtitle.
			bool Erase(const int &id);

			// Erase all TSubtitle matches
			bool EraseAll(const TSubtitle &tc);

			// Erase a position
//			bool Erase(const TListNode *ln);

			string GetText(int id);

			void GetArrayText(string v[]);
			
			vector<TSubtitle*> GetArraySubs(void);

			// profile GetProfile(int id);

		private:
            // First and Last TListNode
			TListNode *first, *last;

			// Get: Subtitle not found
			TSubtitle subt_error;

	};

#endif

